package cool.zhoujie.address.db;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;
import java.util.List;

@Dao
public interface AddressDao {

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insert(Address address);

    @Delete
    void delete(Address address);

    @Query("select * from Address order by isDefault desc")
    List<Address> queryAll();

    @Update(onConflict = OnConflictStrategy.REPLACE)
    void update(Address address);

    //更新default值
    @Query("update Address set isDefault = :isdefault")
    void updateDefault(boolean isdefault);
}
